package com.fxp.project.jiuselu.web.models.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fxp.project.jiuselu.web.business.v1.request.order.ReqOrderConfirmReceipt;
import com.fxp.project.jiuselu.web.models.order.entity.JslOrder;
import com.fxp.project.jiuselu.web.models.order.vo.JslOrderArrearsVo;
import com.fxp.project.jiuselu.web.models.order.vo.JslOrderVo;
import com.fxp.project.jiuselu.web.models.order.vo.JslUserOrderTotalVo;
import com.fxp.project.jiuselu.web.models.order.vo.UserOrderPageVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 订单表 Mapper 接口
 * </p>
 *
 * @author Jason.Wang
 * @since 2021-11-17
 */
public interface JslOrderMapper extends BaseMapper<JslOrder> {

    /**
     * selectJslOrderVoByUserId: 查询当前用户的正常订单信息<br/>
     *
     * @param currentDate
     * @param userId
     * @return
     * @author Kai.Wang
     * @date 2021/11/24 15:35
     */
    List<JslOrderVo> selectJslOrderVoByUserId(@Param("currentDate") LocalDateTime currentDate, @Param("userId") Long userId, @Param("orderTotalStatus") int orderTotalStatus);
    /**
     * selectJslOrderVoByUserId: 查询当前用户的正常订单信息<br/>
     *
     * @param currentDate
     * @param userId
     * @return
     * @author Kai.Wang
     * @date 2021/11/24 15:35
     */
    List<JslOrderVo> selectFareJslOrderVoByUserId(@Param("currentDate") LocalDateTime currentDate, @Param("userId") Long userId, @Param("orderTotalStatus") int orderTotalStatus);

    /**
     * selectJslOrderArrearsVoByUserId: 查询当前的用户的预付款订单<br/>
     *
     * @param currentDate
     * @param userId
     * @return
     * @author Kai.Wang
     * @date 2021/11/24 16:53
     */
    List<JslOrderArrearsVo> selectJslOrderArrearsVoByUserId(@Param("currentDate") LocalDateTime currentDate, @Param("userId") Long userId,@Param("orderTotalStatus") int orderTotalStatus);

    /**
     * selectJslOrderVoByUserIdForBank: 银行承兑的订单列表<br/>
     *
     * @param currentDate
     * @param userId
     * @return
     * @author Kai.Wang
     * @date 2021/11/24 17:59
     */
    List<JslOrderVo> selectJslOrderVoByUserIdForBank(@Param("currentDate") LocalDateTime currentDate, @Param("userId") Long userId);

    /**
     * selectJslOrderVoByUserIdAndOrderId: 根据当前用户的Id和订单Id查询订单详细信息<br/>
     *
     * @param orderId
     * @param userId
     * @return
     * @author Jason.Wang
     * @date 2021/12/26 11:56
     */
    JslOrderVo selectJslOrderVoByUserIdAndOrderId(@Param("orderId") String orderId, @Param("userId") Long userId);

    List<JslOrderVo> selectJslOrderByUserId(@Param("userId") long userId,@Param("addTime") LocalDateTime addTime,@Param("orderTotalStatus") Integer orderTotalStatus);

    /**
     * 全款订单,订单信息+订单剩余时间
     * @param userId
     * @param addTime
     * @param orderTotalStatus
     * @return
     */
    List<JslOrderVo> selectTotalOrderByUserId(@Param("userId") long userId,@Param("addTime") LocalDateTime addTime,@Param("orderTotalStatus") Integer orderTotalStatus);

    List<JslOrderVo> selectBankOrderByUserId(@Param("userId") long userId,@Param("addTime") LocalDateTime addTime,@Param("orderTotalStatus") Integer orderTotalStatus);

    public int deleteOrderByOrderId(String orderId);

    /**
     * selectJslOrderVoByOrderId: 通过当前订单Id查询订单信息<br/>
     *
     * @param orderId
     * @return
     * @author Jason.Wang
     * @date 2021/12/29 0:40
     */
    JslOrderVo selectJslOrderVoByOrderId(String orderId);

    /**
     * @return void
     * @Description 订单确认收货
     * @Date 15:02 2022/1/3
     * @Param [reqOrderConfirmReceipt, userId]
     * @Author M_
     **/
    void orderConfirmReceipt(@Param("reqOrderConfirmReceipt") ReqOrderConfirmReceipt reqOrderConfirmReceipt);

    /**
     * @Description 统计用户所有订单
     * @Date 20:02 2022/1/6
     * @Param [userId]
     * @return com.fxp.project.jiuselu.web.models.order.vo.JslUserOrderTotalVo
     * @Author M_
     **/
    JslUserOrderTotalVo selectUserOrderTotal(@Param("userId") Long userId) ;

    /**
     * @Description 通过userid 获取订单信息
     * @Date 22:44 2022/1/6
     * @Param [userId]
     * @return java.util.List<com.fxp.project.jiuselu.web.models.order.vo.UserOrderPageVo>
     * @Author M_
     **/
    List<UserOrderPageVo> getUserOrderPage(Long userId);

    /**
     * 银行承兑点
     * @return
     */
    BigDecimal getJslTax();

    /**
     * 取消订单修改状态信息
     * @param oderId
     * @return
     */
    int  updateStatus(@Param("orderId") String oderId);

    int updateOrderType(String orderId);

    BigDecimal selectMoneyByUserId(Long userId);

    @Update("update jsl_order set pay_time = #{payTime}  where order_id = #{orderId}")
    void updatePayTime(@Param("payTime")LocalDateTime payTime,@Param("orderId") String orderId);

    /**
     * 创建账号一个月之内未下单
     */
    List<JslOrder> selectJslOrderNearMonth(@Param("userId") Long userId,@Param("addTime") LocalDateTime addTime);
}
